package com.teziyou.commodity.service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.thrift.TException;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.mytravel.commodityBridge.service.ScenicSpotInfoService;
import com.mytravel.commodityBridge.service.bean.ScenicSpot;
import com.teziyou.commodity.core.thrift.ConnectionManager;

@SuppressWarnings("rawtypes")
@Service
public class SceneService {

	@Resource(name="productConnectionManager")
	private ConnectionManager connectionManager;
	
	private ScenicSpotInfoService.Client client;

	public boolean addScene(ScenicSpot scene) {
		try {
			return client.addScene(scene);
		} catch (TException e) {
			throw new RuntimeException(e);
		}
	}

	public boolean deleteSceneById(long id) {
		try {
			return client.deleteSceneById(id);
		} catch (TException e) {
			throw new RuntimeException(e);
		}
	}

	public boolean updateScene(ScenicSpot scene) {
		try {
			return client.updateScene(scene);
		} catch (TException e) {
			throw new RuntimeException(e);
		}
	}

	public List findScenesByPage(
			Map<String, String> condition) {
		try {
			return JSON.parseArray(client.findScenesByPage(condition));
		} catch (TException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}

	public int findScenesCount(Map<String, String> condition) {
		try {
			return client.findScenesCount(condition);
		} catch (TException e) {
			throw new RuntimeException(e);
		}
	}

	public Map findSceneById(long id) {
		try {
			return JSON.parseObject(client.findSceneById(id));
		} catch (TException e) {
			throw new RuntimeException(e);
		}
	}

}
